#ifndef _STATS_H_
#define _STATS_H_



#define _WIN32_DCOM
#include <iostream>
#include <string>
#include <math.h>


using namespace std;
#include <comdef.h>
#include <Wbemidl.h>

#include "stdafx.h"

# pragma comment(lib, "wbemuuid.lib")

struct sCMP
{
	wstring Hostname; 
	wstring Workgroup;
	wstring Manufacturer;
	wstring Model;
	wstring Ip;
	unsigned int NumberOfLogicalProcessors;

};
struct sVCRD
{
	 unsigned int Ram;       // video card memory
	 wstring Producer;       // producer of card
	 wstring Model;          // Model
	 unsigned int v;         // vertical
	 unsigned int h;		 // horizontal
	 unsigned int bpp;       // bit per pixel
	 unsigned int refresh;   // refresh rate
};
struct sVRam
{
	unsigned int Capacity; // in MB
};
struct sCPU
{
	wstring Architecture;
	wstring	Family;
	wstring  Manufacturer;
	float	CurrentClockSpeed;
	float	CurrentVoltage;
	wstring  SocketDesignation;
	unsigned int	UpgradeMethod; // typ gniazda??
	unsigned int	LoadPercentage;
	unsigned int	NumberOfCore;
	unsigned int	NumberOfCPUs;
	float			ExtClock;
};
struct sIOS
{
	wstring companyName;
	wstring productName;
	wstring SystemType;
	wstring OsArchitecture;

};
struct sHDD{
	wstring Interface;    // usb, ide, 1394, scsi etc.
	
	wstring Model;        // ST320171W
	unsigned int Partitions; // 6


};



class GetInfo
{
public:
	GetInfo();
	~GetInfo();
public:
	int InitCOM();
	int SetSecurityLevels();
	int InitLocatorWMI();
	int ConnectToRoot(wstring pathOfWMINamespace);
	int SetProxyLevel();
	int Query(string query);
	int GetData(LPCWSTR attribute, IEnumWbemClassObject* pEnumerator);
	inline IEnumWbemClassObject* GetEnumerator(){return pEnumerator;}
	inline VARIANT getVariant(){return this->vtProp; }

	int Cleanup();
	
public:
	int CMP();  // info about Local host
	int VCRD(); // Video card
	int VRam(); // ram
	int CPU(); // cpu
	int HDD(); // Hard disc drive
	unsigned int CPUUssage();
	int IOS();// operating system

	bool Debug();

	std::wstring StringToWString(std::string& s);
	std::string WStringToString(std::wstring& s);


	VARIANT vtProp;
	IEnumWbemClassObject* pEnumerator;
protected:
	bool _debug;

	HRESULT hres;
	IWbemLocator *pLoc;
	IWbemServices *pSvc;
	
	ULONG uReturn;
	IWbemClassObject *pclsObj;

public:
	sCMP oCMP;
	sIOS oIOS;
	sVRam oVRam;
	sCPU  oCPU;
	sVCRD oVCRD;
	sHDD oHDD;  
};

#endif
